#include <stdio.h>
#include "MTouchware_application.h"

void initAppData(t_applicationData *appData)
{
    appData->input.first = 1;
    appData->input.currentIndex = 0;
    appData->output.first = 1;
    appData->output.currentIndex = 0;

    appData->hasToSend = 0;
    appData->tuioformat = TUIO_2D_CUR; // default
    appData->appServices = STATIONARY;    // default

    return;
}

void setAppLoSender(t_applicationData *appData, lo_address sender)
{
        appData->lo_sender = sender;
}

void debugDisplay(t_applicationData *appData)
{
    int index = appData->input.currentIndex;
    t_touches touches = appData->input.touchdata[index];

    printf("displaying application status :\n");
    printf("   input : currentIndex = %d\n",index);
    printf("         : touchdata[%3d] :\n",index);
    printf("         :                  time        = %lf\n",touches.time);
    printf("         :                  nbTouchInfo = %ld\n",touches.nbTouchInfo);
    printf("         :                  alivelist =");

    int cpt;
    for (cpt=0; cpt < touches.nbTouchInfo; cpt++)
    {
            printf("%ld  ",touches.alivelist[cpt]);
    }
    printf("\n");

    printf("         :                  touchInfoTab\n");

    for(cpt=0; cpt < touches.nbTouchInfo; cpt++)
    {
        printf("                                       input status =");

        switch(touches.touchInfoTab[cpt].input_status)
        {
                case ADDED_NOW :                printf("ADDED_NOW");                break;
                case UPDATED_NOW :              printf("UPDATED_NOW");              break;
                case REMOVED_NOW :              printf("REMOVED_NOW");              break;
                case NOT_IN_CURRENT_BUNDLE :    printf("NOT_IN_CURRENT_BUNDLE");    break;
                default :                       printf("BAD STATUS");               break;
        }

        printf("\n");

        p_touch_values pval = touches.touchInfoTab[cpt].pvalues;

        displayValues(pval);
    }

    return;
}
